//package org.ricks.orm.mongodb.asm;
//
//import org.ricks.common.asm.ClassReader;
//import org.ricks.common.asm.ClassVisitor;
//import org.ricks.common.asm.ClassWriter;
//import org.ricks.common.asm.Opcodes;
//import org.ricks.common.utils.ClassUtils;
//import org.ricks.common.utils.FileUtils;
//
//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
//import java.io.FileOutputStream;
//import java.io.IOException;
//import java.lang.invoke.MethodHandles;
//import java.util.Objects;
//
///**
// * @Author ricks [chenwei]
// * @Version [v1.0]
// * @CreateTime 2024-06-14   18:52
// * @Description TODO
// */
//
//public class HelloWorldTransformCore {
//
//    private static final MethodHandles.Lookup lookup = MethodHandles.lookup();
//
//    public static void main(String[] args) throws IOException, IllegalAccessException {
//        String path = Objects.requireNonNull(HelloWorldTransformCore.class.getResource("")).getPath();
//        System.err.println(path);
//
//        String relative_path = path + "HelloWorld.class";
//        FileInputStream fileInputStream = new FileInputStream(relative_path);
//
//        //（1）构建ClassReader
//        ClassReader cr = new ClassReader(fileInputStream);
//
//        //（2）构建ClassWriter
//        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
//
//        //（3）串连ClassVisitor
//        int api = Opcodes.ASM9;
//        ClassVisitor cv = new MethodParameterVisitor2(api, cw);
//
//        //（4）结合ClassReader和ClassVisitor
//        int parsingOptions = ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES;
//        cr.accept(cv, parsingOptions);
//
//        //（5）生成byte[]
//        byte[] bytes2 = cw.toByteArray();
//
//        Class<HelloWorld> klass = (Class<HelloWorld>) lookup.defineClass(bytes2);
//        HelloWorld helloWorld = ClassUtils.newInstance(klass);
////        FileOutputStream fos = new FileOutputStream(relative_path);
////        fos.write(bytes2);
////        fos.close();
//        helloWorld.sub(1,2);
//
//
//        helloWorld.add(2,5);
//
//
//        helloWorld.div(5,7);
//    }
//}